package client;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JButton;
import javax.swing.JPanel;

public class ConnectedPanel extends JPanel{
    private static final long serialVersionUID = 1L;

    Client client;
	JButton startButton;
	boolean mouseInside;
	
	public ConnectedPanel(Client client){
		this.client = client;
		
		// Listen to clicks
		addMouseListener(new PanelMouse());
		
		// Not inside the menu panel
		mouseInside = false;
	}
	
	@Override
	public void paintComponent(Graphics g){
	    // Hover effect
		if(mouseInside){
			g.setColor(Color.lightGray);
			g.drawRect(0,0,92, 29);
		}
	}

	private class PanelMouse implements MouseListener{
		@Override
		public void mouseClicked(MouseEvent arg0) {
            mouseInside = false;
		    client.showMenu();
		}

		@Override
		public void mouseEntered(MouseEvent arg0) {
			mouseInside = true;
			client.frame.repaint();
		}

		@Override
		public void mouseExited(MouseEvent arg0) {
			mouseInside = false;
			client.frame.repaint();
		}

		@Override
		public void mousePressed(MouseEvent arg0) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void mouseReleased(MouseEvent arg0) {
			// TODO Auto-generated method stub
			
		}
	}
}
